/**
 * 
 */
package com.wubo.sec.acl;

import com.wubo.sec.SecurityManager;
import com.wubo.sec.acl.core.AclManager;
import com.wubo.sec.acl.core.EntityAcl;
import com.wubo.sec.model.Group;

/**
 * @author WuBo
 * @CreateDate 2012-4-23
 */
public class GroupAcl extends EntityAcl {
	private Group group;
	public GroupAcl(Group group){
		this.group = group;
	}
	
	@Override
	public int getAcl() {
		Group curgroup = SecurityManager.getCurrentUser().getGroup();
		
		boolean markLocked = curgroup.isMarkLocked();
		String mark = curgroup.getMark();
		
		if(curgroup.getPriority() > group.getPriority() && 
				(! markLocked || group.getMark().equals(mark)) ){
			return AclManager.getInstance().getAllAcl();
		}

		return 0;
	}
}
